package com.sdlogan.pbudget;

import android.util.Log;

/**
 * The class to hold the variables found in the database
 * @author Sean
 *
 */
public class dbPackage {
		String type;
		String desc;
		double value;
		String category;
		long id;
		String occurence;
		String month;
		String day;
		String year;
		double monthlyvalue;
		double yearlyvalue;
		
		/**
		 * Constructor method
		 */
		public dbPackage() {
			monthlyvalue =0.0;
			yearlyvalue = 0.0;
		}
		
		public void setCategory(String c) {
			this.category = c;
		}
		
		public void setOccurence(String o) {
			this.occurence = o;
		}
		
		public void setMonth(String m) {
			this.month = m;
		}
		
		public void setDay(String d) {
			this.day = d;
		}
		
		public void setYear(String y) {
			this.year = y;
		}
		
		public void setType(String t) {
			this.type = t;
		}
		public void setDescrip(String d) {
			this.desc = d;
		}
		public void setValue(String v) {
			value = Double.parseDouble(v);
		}
		public void setYearlyValue(String s) {
			double temp = Double.parseDouble(s);
			if (occurence.equals("One-Time")) {
				yearlyvalue = temp;
			}
			else if (occurence.equals("Weekly")) {
				yearlyvalue = 52*temp;
			}
			else if (occurence.equals("Bi-Weekly")) {
				yearlyvalue = 26*temp;
			}
			else if (occurence.equals("Monthly")) {
				yearlyvalue = 12*temp;
			}
			else if (occurence.equals("Quarterly")) {
				yearlyvalue = 4*temp;
			}
			else if (occurence.equals("Bi-Yearly")) {
				yearlyvalue = 2*temp;
			}
			else {
				yearlyvalue = temp;
			}
		}
		public void setMonthlyValue(String s) {
			double temp = Double.parseDouble(s);
			if (occurence.equals("One-Time")) {
				monthlyvalue = temp;
			}
			else if (occurence.equals("Weekly")) {
				monthlyvalue = 4*temp;
			}
			else if (occurence.equals("Bi-Weekly")) {
				monthlyvalue = 2*temp;
			}
			else if (occurence.equals("Monthly")) {
				monthlyvalue = temp;
			}
			else if (occurence.equals("Quarterly")) {
				monthlyvalue = temp*4/12;
			}
			else if (occurence.equals("Bi-Yearly")) {
				monthlyvalue = temp*2/12;
			}
			else {
				monthlyvalue = temp/12;
			}
		}
		public void setID(long i) {
			this.id = i;
		}
		public String getType() {
			return type;
		}
		public String getDesc() {
			return desc;
		}
		public double getValue() {
			return value;
		}
		public long getID() {
			return id;
		}
		/**
		 * Return the string representation of the object
		 */
		public String toString() {
			return (type+","+desc+","+value+","+category+","+occurence+","+month+","+day+","+year+","+monthlyvalue+","+yearlyvalue);
		}
}
